home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / CDROM / CD-Finder / CD-Finder_demo.p < prev    next >
Text File  |  1997-11-23  |  50KB  |  1,627 lines

  1. ; CD-Finder
  2. ; (c) 1997 Cyborg 
  3.  
  4.     {* Include sys:coder/preass/Options.p *}
  5.     {* Include sys:coder/preass/Prozeduren.p *}
  6.  
  7.     Include sys:coder/include/Datatypes/datatypes.i
  8.     Include sys:coder/include/intuition/icclass.i
  9.  
  10.     {* NewProc=TerminateString[Buffer][A0]*}
  11.     {* NewProc=Export[][]*}
  12.     {* NewProc=DirTree[][]*}
  13.     {* NewProc=DrawTree_SUB[][a2]*}
  14.     
  15.     {* IncSysBlock: IndexNodeSpeicher,5024*}
  16.     {* IncSysBlock: SelectedNodeSpeicher,5024*}
  17.     {* IncSysBlock: IndexItems,1024*}
  18.     {* IncSysBlock: FIB,300*}
  19.     {* IncBlock: Buffer,1000*}
  20.     {* IncBlock: Buffer1,100*}
  21.     {* IncBlock: CDName,50*}
  22.     {* IncVar: IndexNodeZeiger,Files1,Files,Dirs1,Dirs,Von*}
  23.  
  24.        {* Array[Long]: Cycle_labs,Pipe_Lab,Kcon_lab,PRT_Lab,File_lab*}
  25.        {* Array[Long]: Dateitype_Labs,ASCII,CVS_TAB,CVS_SPACE,CVS_SEMI,CVS_Komma,SYLK,Lotus*}
  26.  
  27.     {* String: Pipe_Lab="Pipe:Export"*}
  28.     {* String: KCON_Lab="KCON:"*}
  29.     {* String: PRT_Lab="PRT:"*}
  30.     {* String: File_Lab="File:"*}
  31.     {* String: ASCII="Nur Text"*}
  32.     {* String: CVS_Tab="CVS Tab"*}
  33.     {* String: CVS_Space="CVS Space"*}
  34.     {* String: CVS_Semi="CVS ;"*}
  35.     {* String: CVS_Komma="CVS ,"*}
  36.     {* String: SYLK="Sylk Excel-4+"*}
  37.     {* String: Lotus="Lotus 1-2-3"*}
  38.     {* String: Version="$VER: CD-Finder 1.1 DEMOVersion (C) CYBORG 97"*}
  39.     {* String: DoItText="Ja|Nein|Neuer Name"*}
  40.  
  41.     {* InitMinList: Index_Labs*}
  42.     {* InitMinList: Selected_Labs*}
  43.  
  44.     Eintraglaenge= 32
  45.  
  46. SECTION A,DATA
  47.  
  48. even
  49. TopazAttr:
  50.     dc.l TopazName
  51.     dc.w 8
  52.     dc.b 0,0
  53. Topazname:
  54.     dc.b "topaz.font",0
  55.     blk.b 29,0
  56.  
  57. SECTION B,CODE
  58.  
  59. AminetCheck[D7]:
  60.     Read(D7,#Buffer,1)
  61.     Seek(D7,#-1,#Offset_Current)
  62.     cmpi.b #"|",Buffer
  63.     beq .Aminet
  64.     move.l #-1,d0
  65.     RTS
  66. .aminet:
  67.     Result=Fgets(Handle,#Buffer,1000)
  68.     If Result##Buffer -> .ende
  69.     cmpi.b #"|",buffer
  70.     beq .aminet
  71. .Schleife:
  72.     Result=Fgets(Handle,#Buffer,1000)
  73.     If Result##Buffer -> .ende
  74.     move.l buffer,a0
  75. .l1:cmpi.b #" ",(a0)+
  76.     bne .l1
  77.     lea -1(a0),a1
  78. .l2:cmpi.b #" ",(a0)+
  79.     beq .l2
  80.     lea -1(a0),a2
  81. .l3:cmpi.b #" ",(a0)+
  82.     bne .l3
  83.     lea -1(a0),a3
  84.     move.l a3,d3
  85.     sub.l a2,d3
  86.     move.l a1,d2
  87.     sub.l #Buffer,d2
  88.     movem.l d0-d3/a0-a3,-(a7)
  89.     Copymem(a2,#Buffer1,d3)
  90.     movem.l (a7)+,d0-d3/a0-a3
  91.     FIB=="AMINET:"+Left$(Buffer1,d3)+"/"+Left$(Buffer,d2)+"\n"
  92.     OK=Countstring(#FIB)
  93.     Write(WH,#FIB,OK)
  94.     beq .Schleife
  95. .ende:
  96.     moveq.l #0,d0
  97.     RTS
  98.  
  99. Prefs[]:
  100.     IndexWindow=OpenGuiWindowA(000,011,300,110,"CD-Finder Prefs",
  101.                   #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_CLOSEWINDOW!IDCMP_IDCMPupdate,
  102.                   #WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_RMBTRAP!0,0,0)
  103.     Checkf IndexWindow,WaitMessage
  104.     IndexGUI=CreateGuiInfoA(IndexWindow,0)
  105.     CreateGuiGadgetA(IndexGui,10,10,200,013,#CheckBox_Kind,
  106.      >GadgetP00Tags:GEG_Description,0|
  107.                     GEG_Text,GadgetP00Text="Suche in einem File"|
  108.                     GEG_Flags,002|
  109.                     Tag_done,0)
  110.     {* IncVar: SearchOnly*}
  111.     CreateGuiGadgetA(IndexGui,10,25,200,013,#CheckBox_Kind,
  112.      >GadgetP01Tags:GEG_Description,0|
  113.                     GEG_Text,GadgetP01Text="Anzeige beim Scannen"|
  114.                     GEG_Flags,002|
  115.                     Tag_done,0)
  116.     DrawGuiA(IndexGui,0)
  117. .WaitMessage:
  118.     {* Flush *}
  119.     WaitGuiMsg(IndexGui)
  120.     MsgClass=.l36(IndexGui)
  121.     If MsgClass##IDCMP_CloseWindow  --> .WaitMessage
  122.     CloseGuiWindow(IndexWindow)
  123.     RTS
  124.  
  125. Cnop 0,4
  126. Open_Window:
  127.     Window=OpenGuiWindowA(000,011,640,50,"CD-Finder",
  128.             #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_CLOSEWINDOW!IDCMP_VANILLAKEY!IDCMP_RAWKEY!0,
  129.             #WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_RMBTRAP!0,0,0)
  130.     Checkf Window,Open_Windowende
  131.     GUI=CreateGuiInfoA(Window,0)
  132. Open_Windowende:RTS
  133.  
  134. Create_Gadgets:
  135.     CreateGuiGadgetA(Gui,070,005,100,012,#String_Kind,
  136.             >Gadget000Tags:GEG_Description,0|
  137.                 GEG_Text,GADGET000Text="_Device:"|
  138.                 GEG_Flags,001|
  139.                 GEG_Varaddress,Device|
  140.                 Tag_done,0)
  141.  
  142.     {* IncSysBlock: Device,100*}
  143.     CreateGuiGadgetA(Gui,005,020,080,012,#Button_Kind,
  144.             >Gadget001Tags:GEG_Description,0|
  145.                 GEG_Text,GADGET001Text="S_can"|
  146.                 GEG_Flags,016|
  147.                 Tag_done,0)
  148.  
  149.     CreateGuiGadgetA(Gui,090,020,080,012,#Button_Kind,
  150.             >Gadget002Tags:GEG_Description,0|
  151.                 GEG_Text,GADGET002Text="_Edit"|
  152.                 GEG_Flags,016|
  153.                 Tag_done,0)
  154.  
  155.     CreateGuiGadgetA(Gui,175,020,080,012,#Button_Kind,
  156.             >Gadget003Tags:GEG_Description,0|
  157.                 GEG_Text,GADGET003Text="_Suche"|
  158.                 GEG_Flags,016|
  159.                 Tag_done,0)
  160.  
  161.     CreateGuiGadgetA(Gui,230,005,400,012,#String_Kind,
  162.             >Gadget004Tags:GEG_Description,0|
  163.                 GEG_Text,GADGET004Text="_Text"|
  164.                 GEG_Flags,001|
  165.                 GEG_Varaddress,SuchText|
  166.                 Tag_done,0)
  167.  
  168.     {* IncSysBlock: SuchText,100*}
  169.     CreateGuiGadgetA(Gui,260,020,127,012,#Button_Kind,
  170.             >Gadget005Tags:GEG_Description,0|
  171.                 GEG_Text,GADGET005Text="_Importieren"|
  172.                 GEG_Flags,048|
  173.                 Tag_done,0)
  174.  
  175.     CreateGuiGadgetA(Gui,390,020,240,06,#GEG_ProgressIndicatorKind,
  176.             >Gadget006Tags:GEG_Description,0|
  177.                    GEG_Flags,016|
  178.                 Tag_done,0)
  179.  
  180.     CreateGuiGadgetA(Gui,390,027,240,06,#GEG_ProgressIndicatorKind,#Gadget006Tags)
  181.     {* IncVar: Pro*}
  182.     CreateGuiGadgetA(Gui,005,034,080,012,#Button_Kind,
  183.             >Gadget008Tags:GEG_Description,0|
  184.                 GEG_Text,GADGET008Text="I_ndex"|
  185.                 GEG_Flags,016|
  186.                 Tag_done,0)
  187.     CreateGuiGadgetA(Gui,090,034,080,012,#Button_Kind,
  188.             >Gadget009Tags:GEG_Description,0|
  189.                 GEG_Text,GADGET009Text="In_fo"|
  190.                 GEG_Flags,016|
  191.                 Tag_done,0)
  192.     CreateGuiGadgetA(Gui,260,034,127,012,#Button_Kind,
  193.             >Gadget010Tags:GEG_Description,0|
  194.                 GEG_Text,GADGET010Text="E_xportieren"|
  195.                 GEG_Flags,048|
  196.                 Tag_done,0)
  197.  
  198.     CreateGuiGadgetA(Gui,175,034,080,012,#Button_Kind,
  199.             >Gadget011Tags:GEG_Description,0|
  200.                 GEG_Text,GADGET011Text="T_ree"|
  201.                 GEG_Flags,016|
  202.                 Tag_done,0)
  203.  
  204.     CreateGuiGadgetA(Gui,390,034,080,012,#Button_Kind,
  205.             >Gadget012Tags:GEG_Description,0|
  206.                 GEG_Text,GADGET012Text="_Prefs"|
  207.                 GEG_Flags,016|
  208.                 Tag_done,0)
  209.  
  210.     Result=DrawGuiA(Gui,0)
  211.     RTS
  212.  
  213. Close_Window:
  214.     CloseGuiWindow(Window)
  215.     RTS
  216.  
  217.  
  218. WritePlain[d7]:
  219.         Convertzahl(D7,0)
  220.         Zeiger==#Zusatz
  221.         Anz==8
  222. .Write_Sylk_test1:
  223.         Wert=.b(Zeiger)
  224.         cmpi.l #$00000020,Wert
  225.         bne .Write_Sylk_Test2
  226.         Zeiger==Zeiger++
  227.         Anz==Anz--
  228.         bra .Write_Sylk_test1
  229. .Write_Sylk_test2:
  230.         Write(WH,Zeiger,anz)
  231.         RTS
  232.  
  233. CountCells[a0]:
  234.     moveq.l #0,d0
  235. .count:
  236.     lea 1(a0),a0
  237.     addq.l #1,d0
  238. .CountCells1:
  239.     cmpi.b #`:`,(a0)
  240.     beq .count
  241.     cmpi.b #`/`,(a0)
  242.     beq .Count
  243.     cmpi.b #$0a,(a0)
  244.     beq .ende
  245.     cmpi.b #$00,(a0)
  246.     beq .ende
  247.     lea 1(a0),a0
  248.     bra .CountCells1
  249. .ende:
  250.     RTS
  251.  
  252. WriteZelle[a0,d1]:
  253.     moveq.l #0,d0
  254. .count:
  255.     addq.l #1,d0
  256.     cmpi.l d0,d1
  257.     beq .write
  258.     lea 1(a0),a0
  259. .CountCells1:
  260.     cmpi.b #`:`,(a0)
  261.     beq .count
  262.     cmpi.b #`/`,(a0)
  263.     beq .Count
  264.     lea 1(a0),a0
  265.     bne .CountCells1
  266. .Write:
  267.     cmpi.l #1,d1
  268.     beq .write0
  269.     lea 1(a0),a0
  270. .write0:
  271.     move.l a0,a1
  272. .weiter:
  273.     cmpi.b #`:`,(a0)
  274.     beq .next
  275.     cmpi.b #`/`,(a0)
  276.     beq .next
  277.     cmpi.b #$0a,(a0)
  278.     beq .next
  279.     cmpi.b #$00,(a0)
  280.     beq .next
  281.     lea 1(a0),a0
  282.     bra .weiter
  283. .next:
  284.     sub.l a1,a0
  285.     Write(WH,a1,a0)
  286.     RTS
  287.  
  288. TestFilename[D7,a0]:
  289.     NamefromFH(D7,#Buffer,1000)                      
  290.     Seek(D7,0,#Offset_end)
  291.     Laenge=Seek(d7,0,#Offset_begin)
  292.     Memoryblock=AllocMem(Laenge,#MEMF_CLEAR!MEMF_PUBLIC)
  293.     CheckF MemoryBlock,.error
  294.     Read(d7,Memoryblock,Laenge)
  295.     Move.l Memoryblock,d0
  296.     RTS
  297. .Error:
  298.     Moveq.l #0,d0
  299.     RTS
  300.  
  301. {* NewProc=TerminateString[Buffer][A0]*}
  302. TerminateString:
  303.     move.l a0,-(a7)
  304. .l1:cmpi.b #$00,(a0)
  305.     beq .ende
  306.     cmpi.b #$0a,(a0)
  307.     beq .Term
  308.     lea 1(a0),a0
  309.     bra.s .l1
  310. .Term:
  311.     move.b #$00,(a0)
  312. .ende:
  313.     move.l (a7)+,a0
  314.     RTS
  315.  
  316. RGets[A0]:
  317.     TerminateString(a0)
  318.     move.l memoryblock,a1
  319.     add.l Laenge,a1
  320.     cmp.l a0,a1
  321.     ble .error
  322.     moveq.l #1,d0
  323.     RTS
  324. .error:
  325.     moveq.l #0,d0
  326.     RTS
  327.  
  328. RGets2[A0]:
  329.     OK=Countstring(a0)
  330.     move.l a0,a1
  331.     add.l Ok,a1
  332.     addi.l #1,a1
  333.     move.l memoryblock,a0
  334.     add.l len,a0
  335.     cmpa.l a0,a1
  336.     bge .l1
  337.     move.l a1,d0
  338.     RTS
  339. .l1:
  340.     moveq.l #0,d0
  341.     RTS
  342.  
  343. Progress[Gadget,Prozent]:
  344.     {* IncVar: Prozent,Gadget*}
  345.     Lea SetProgressTags,a0
  346.     move.l Prozent,4(a0)
  347.     SetGUIGadgetA(gui,Gadget,>SetProgressTags:GEG_PICurrentValue,0|
  348.                                               Tag_Done,NULL)
  349.     RTS
  350.  
  351. Copy[d6,d7]:
  352.     anz=Read(d6,#Buffer,1000)
  353.     anz=Write(d7,#Buffer,anz)
  354.     If Anz=#1000 --> Copy
  355.     RTS
  356.  
  357. SetPfad[]:
  358.     FPuts(TH,#Pfad)
  359.     OK=CountString(#pfad)
  360.     Lea PFad,a0
  361.     add.l ok,a0
  362. .l1:cmpi.b #"/",(a0)
  363.     beq .Thatsit
  364.     cmpi.b #":",(a0)
  365.     beq .Thatsit
  366.     lea -1(a0),a0
  367.     bra .l1
  368. .ThatsIt:
  369.     move.b #0,1(a0)
  370.     OK=CountString(#pfad)
  371.     RTS    
  372.  
  373. SetPfad_Crunch[]:
  374.     FPuts(TH,#Pfad)
  375.     OK=CountString(#pfad)
  376.     WriteLaenge==Writelaenge+OK
  377.     ReadLaenge==Readlaenge+OK
  378.     Lea PFad,a0
  379.     add.l ok,a0
  380. .l1:cmpi.b #"/",(a0)
  381.     beq .Thatsit
  382.     cmpi.b #":",(a0)
  383.     beq .Thatsit
  384.     lea -1(a0),a0
  385.     bra .l1
  386. .ThatsIt:
  387.     lea 1(a0),a0
  388.     move.b #0,(a0)+
  389.     RTS
  390.  
  391. SetPfad_Compare[]:
  392.     OK=CountString(#pfad2)
  393.     Lea PFad2,a0
  394.     add.l ok,a0
  395. .l1:cmpi.b #"/",(a0)
  396.     beq .Thatsit
  397.     cmpi.b #":",(a0)
  398.     beq .Thatsit
  399.     lea -1(a0),a0
  400.     bra .l1
  401. .ThatsIt:
  402.     lea 1(a0),a0
  403.     move.b #0,(a0)+
  404.     RTS
  405.  
  406. ComparePfad[a0,a1]:
  407.     move.b (a0)+,d0
  408.     move.b (a1)+,d1
  409.     cmpi.b d0,d1
  410.     bne .dismatch
  411.     cmpi.b #0,(a0)
  412.     bne ComparePfad
  413.     moveq.l #-1,d0
  414.     RTS
  415. .dismatch:
  416.     moveq.l #0,d0
  417.     RTS
  418.  
  419.  
  420. Crunch[Handle]:
  421.     Progress(6,50)
  422.     Counter==Counter*2
  423.     Count==0
  424.     ReadLaege==0
  425.     Writelaenge==0
  426.     Move.l Handle,-(a7)
  427.     Move.l TH,-(a7)
  428.     Move.l OK,-(a7)
  429.     Move.l Result,-(a7)
  430.     Handle=Open(Handle,#Mode_old)
  431.     TH=Open("t:swap.crunch",#mode_new)
  432.     Write(TH,"CM01\n",5)
  433.     Result=Fgets(Handle,#Pfad,150)
  434.     If Result##Pfad -> .ende
  435. .l0:
  436.     SetPfad_Crunch()
  437.     Copymem(#pfad,#Pfad_1,150)
  438. .l1:    
  439.     Pro==Writelaenge*100
  440.     Pro==Pro/ReadLaenge
  441.     Progress(7,Pro)
  442.     Count==Count+1
  443.     Pro==Count*100
  444.     Pro==Pro/Counter
  445.     Pro==Pro+50
  446.     Progress(6,Pro)
  447.     Result=Fgets(Handle,#Pfad,150)
  448.     If Result##Pfad -> .ende1
  449.     OK=Countstring(#Pfad)
  450.     Readlaenge==Readlaenge+ok
  451.     Copymem(#pfad,#Pfad2,150)
  452.     SetPfad_Compare()
  453.     Match=ComparePfad(#Pfad2,#Pfad_1)
  454.     CheckF Match,.l0
  455.     Fwrite(TH,"%",1,1)
  456.     OK=Countstring(#Pfad)
  457.     lea pfad,a0
  458.     add.l ok,a0
  459. .l2:cmpi.b #"/",(a0)
  460.     beq .Thatsit
  461.     cmpi.b #":",(a0)
  462.     beq .Thatsit
  463.     lea -1(a0),a0
  464.     bra .l2
  465. .ThatsIt:
  466.     lea 1(a0),a0
  467.     move.l a0,Result
  468.     OK=Countstring(Result)
  469.     Fwrite(TH,Result,ok,1)
  470.     OK==OK+1
  471.     WriteLaenge==Writelaenge+OK
  472.     bra .l1
  473. .ende1:
  474.     Seek(TH,0,#Offset_begin)
  475.     NamefromFH(Handle,#pfad,150)
  476.     Close(Handle)
  477.     Handle=Open(#Pfad,#Mode_new)
  478.     Copy(TH,Handle)
  479.     Close(TH)
  480.     Close(handle)
  481.     Deletefile("T:swap.crunch")
  482.     bra .ende2
  483. .Ende:
  484.     Close(TH)
  485.     Close(handle)
  486. .ende2:
  487.     Move.l (a7)+,Result
  488.     Move.l (a7)+,OK
  489.     Move.l (a7)+,TH
  490.     Move.l (a7)+,Handle
  491.     Progress(6,100)
  492.     RTS
  493.  
  494. Decrunch[Handle]:
  495.     {* IncsysBlock: Pfad,150*}
  496.     {* IncsysBlock: Pfad_1,150*}
  497.     {* IncsysBlock: Pfad2,150*}
  498.     {* IncVar: Handle*}
  499.     Countfiles==1
  500.     CountDirs==1
  501.     MaxZellen==0
  502.     Move.l Handle,-(a7)
  503.     Move.l TH,-(a7)
  504.     Move.l OK,-(a7)
  505.     Move.l Result,-(a7)
  506.     move.l handle,a0
  507.     move.l (a0),Handle
  508.     Fgets(Handle,#Pfad,150)
  509.     If Pfad##"CM01" --> .Ende
  510.     TH=Open("t:swap.decrunch",#mode_new)
  511.     Result=Fgets(Handle,#Pfad,150)
  512.     If Result##Pfad -> .ende
  513.     bra .l0
  514. .l00:
  515.     CopyMem(#Pfad_1,#Pfad,150)
  516. .l0:
  517.     Countdirs==Countdirs++
  518.     SetPfad()
  519. .l1:    
  520.     Result=Fgets(Handle,#Pfad_1,150)
  521.     If Result##Pfad_1 -> .ende1
  522.     Zellen=CountCells(#pfad_1)
  523.     If Zellen>maxZellen {
  524.                           maxZellen==Zellen
  525.                         }
  526.     Countfiles==Countfiles++
  527.     Cmpi.b #"%",pfad_1
  528.     bne .l00
  529.     FWrite(TH,#Pfad,OK,1)
  530.     FPuts(TH,#Pfad_1+1)
  531.     bra .l1
  532. .ende1:
  533.     Close(Handle)
  534.     move.l TH,D7
  535.     Seek(D7,0,#Offset_Begin)
  536.     Move.l (a7)+,Result
  537.     Move.l (a7)+,OK
  538.     Move.l (a7)+,TH
  539.     Move.l (a7)+,a0
  540.     move.l D7,(a0)
  541.     RTS
  542. .ende:
  543.     Seek(Handle,0,#Offset_Begin)
  544.     Move.l (a7)+,Result
  545.     Move.l (a7)+,OK
  546.     Move.l (a7)+,TH
  547.     Move.l (a7)+,Handle
  548.     RTS
  549.  
  550. Progressfiles[]:
  551.     {* IncVar: Merker*}
  552.     Counter==Counter+1
  553.     Files==Files+1
  554.     If Files<#10 --> .ende
  555.     Files==0
  556.     Merker==Merker+1
  557.     If Merker<#101 --> .l1
  558.     Merker==0 
  559. .l1:
  560.     Lea SetProgressTags,a0
  561.     move.l Merker,4(a0)
  562.     SetGUIGadgetA(gui,7,#SetProgressTags)
  563. .ende:
  564.     RTS
  565.  
  566. ProgressReadlines[]:
  567.     Counter==Counter+1
  568.     If Counter<#10 --> .ende
  569.     Counter==0
  570.     Merker==Merker+1
  571.     If Merker<#101 --> .l1
  572.     Merker==0 
  573. .l1:
  574.     Lea SetProgressTags,a0
  575.     move.l Merker,4(a0)
  576.     SetGUIGadgetA(gui,7,#SetProgressTags)
  577. .ende:
  578.     RTS
  579.  
  580. GetCDName[a0]
  581.     Dirlock=Lock(a0,#Access_read)
  582.     NameFromLock(Dirlock,#CDName,100)
  583.     CheckF Dirlock,.ende
  584.     Unlock(Dirlock)
  585. .ende:
  586.     RTS
  587.  
  588. GetIndex[]:
  589.     Zahl==0
  590.     Dirlock=Lock("Base-CD:",#access_read)
  591.     FillBuffer(#Fib,0,300)
  592.     Examine(Dirlock,#FIB)
  593. .Schleife:
  594.     Zahl==Zahl+1
  595.     OK=ExNext(Dirlock,#FIB)
  596.     CheckT Ok,.Schleife
  597.     Unlock(Dirlock)
  598.     move.l Zahl,d0
  599.     RTS
  600.  
  601. Anhaengen[]:
  602.     Result=GuiRequestA(Gui,"Schon vorhanden anhängen?",#GER_YNCkind,>DOITTags:GER_Gadgets,DOITTEXT|Tag_done,Null)
  603.     If Result=#GER_No {
  604.                        Close(FH)
  605.                        FH=Open(#Buffer,#Mode_new)
  606.                       }
  607.     If Result=#GER_Cancel {
  608.                             {* Flush *}
  609.                             Close(FH)
  610.                             Copymem("Base-CD:\$00",#Dirname,?)
  611.                             Copymem(".index\$00",#Filename,?)
  612.                             FileReq(0)
  613.                             {* Flush *}
  614.                             FH=Open(#Name_bak,#Mode_new)
  615.                           }
  616.     {* Flush *}
  617.     Seek(FH,0,#Offset_end)
  618.     RTS
  619.  
  620. EinScannen[]:
  621.     IndexWindow=OpenGuiWindowA(000,011,640,255,"CD-Finder Directoryindex",
  622.             #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_CLOSEWINDOW!IDCMP_IDCMPupdate,
  623.             #WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_RMBTRAP!0,0,0)
  624.     Checkf IndexWindow,.ende
  625.     IndexGUI=CreateGuiInfoA(IndexWindow,0)
  626.     NewObject=NewDTObjectA(#Buffer,>NewDTTAGS:GA_Left,5|GA_TOP,11|
  627.                                                       GA_Width,630|GA_Height,248|
  628.                                                       GA_ID,1|
  629.                                                       ICA_Target,ICTARGET_IDCMP|
  630.                                                       Tag_done,Null)
  631.     AddDTObject(IndexWindow,0,NewObject,-1)
  632. .WaitMessage:
  633.     {* Flush *}
  634.     WaitGuiMsg(IndexGui)
  635.     MsgClass=.l36(IndexGui)
  636.     MsgGadNbr=.w52(IndexGui)
  637.     MsgChar=.b43(IndexGui)
  638.     If MsgClass=#IDCMP_IDCMPUpdate {
  639.                                      RefreshDTObjectA(NewObject,IndexWindow,0,0)
  640.                                      Bra .WaitMessage
  641.                                    }
  642.     If MsgClass##IDCMP_CloseWindow  --> .WaitMessage
  643.     {* Flush *}
  644.     RemoveDTObject(IndexWindow,NewObject)
  645.     DisposeDTObject(NewObject)
  646.     CloseGuiWindow(IndexWindow)
  647. .ende:
  648.     RTS
  649.  
  650. Start:
  651.     STATUS==1
  652.     OO==0
  653.     IF (TH=Open("Env:Cd-Finder.dat",#Mode_old))##0 {
  654.                                                      Read(TH,#Status,4)
  655.                                                      Read(TH,#Searchonly,4)
  656.                                                      Close(TH)
  657.                                                    }
  658.     OH=Open("Kcon://640/200/CD-Finder/AUTO/CLOSE/WAIT",#mode_old)
  659.     If OH=#0 {
  660.                OO==1
  661.                OH=Output()
  662.              }
  663.     CD("Base-CD:")
  664.     CopyMem("CD0:",#Device,?)
  665.     Jsr Open_Window
  666.     CheckF Window,PRG_Ende
  667.     Jsr Create_Gadgets
  668.     CheckF Result,WaitMessage
  669.     GuiRequestA(Gui,"GadgetError!",#GER_OKKind,#OKTAGS)
  670.     Bra PRG_Ende
  671. WaitMessage:
  672.     WaitGuiMsg(Gui)
  673.     MsgClass=.l36(Gui)
  674.     MsgGadNbr=.w52(Gui)
  675.     If MsgClass=#IDCMP_CloseWindow --> PRG_Ende
  676.     If MsgClass##IDCMP_GadgetUp -----> WaitMessage
  677.     GuiGadgetActiona(Gui,>Gettags:GEG_GetVar,GEG_Allgadgets|
  678.                                   Tag_done,Null)
  679.     If MsgGadNbr=#1 {
  680.                       Files==0
  681.                       Dirs==0
  682.                       Counter==0
  683.                       Merker==0
  684.                       Progress(6,0)
  685.                       GetCDName(#Device)
  686.                       Buffer=="Die CD heißt: "+CDName
  687.                       GuiRequestA(Gui,#buffer,#GER_Okkind,>OKTags:GER_Gadgets,OKTEXT="Weiter"|Tag_Done,Null)
  688.                       OK=Countstring(#CDName)
  689.                       Buffer=="Base-CD:"+Left$(CDName,ok)+".Index"
  690.                       FH=Open(#Buffer,#mode_old)
  691.                       If FH##0 { 
  692.                                  Anhaengen()
  693.                                }
  694.                       If FH=#0 { 
  695.                                  FH=Open(#Buffer,#Mode_new)
  696.                                }
  697.                       CD(#Device)
  698.                       CDlock=Lock(#Device,#Access_read)
  699.                       CheckF CDLock,CantLock
  700.                       Move.l a7,a5
  701. .Schleife:
  702.                       {* Flush *}
  703.                       OK=Examine(CDLock,#FIB)
  704.                       CheckF FH,CDENDEError
  705. .Schleife1:
  706.                       {* Flush *}
  707.                       OK=ExNext(CDLock,#FIB)
  708.                       CheckF OK,.dirende
  709.                       Progressreadlines()
  710.                       Type=.l4(#FIB)
  711.                       If Type>#0 --> .dir
  712.                       Zeiger=8(#FIB)
  713.                       Filelock=Lock(Zeiger,#Access_read)
  714.                       NameFromLock(Filelock,#Buffer,100)
  715.                       Unlock(Filelock)
  716.                       OK=Countstring(#Buffer)
  717.                       If Status=#0 --> .skippy 
  718.                       Copymem(#Buffer,#SuchText,100)
  719.                       GuiGadgetActiona(Gui,>Settags:GEG_SetVar,GEG_Allgadgets|
  720.                                                     Tag_done,Null)
  721. .skippy:              
  722.                       {* Flush *}
  723.                       Files==Files++
  724.                       Write(FH,#Buffer,ok)
  725.                       Write(FH,"\n",1)
  726.                       Bra .Schleife1
  727. .dir:
  728.                       {* Flush *}
  729.                       Counter==Counter-1
  730.                       Zeiger=8(#FIB)
  731.                       Dummy=Lock(Zeiger,#Access_read)
  732.                       Move.l Dummy,-(a7)
  733.                       Dirs==Dirs++
  734.                       Bra .Schleife1
  735. .dirende:
  736.                       {* Flush *}
  737.                       Cmp.l a5,a7
  738.                       Beq .dirende1
  739.                       Unlock(CDLock)
  740.                       Move.l (a7)+,CDLOCK
  741.                       l=Currentdir(CDLOCK)
  742.                       unlock(l)
  743.                       FillBuffer(#FIB,0,300)
  744.                       bra .Schleife
  745. .dirende1:
  746.                       {* Flush *}
  747.                       Close(FH)
  748.                       Progress(6,50)
  749.                       FillBuffer(#SuchText,0,100)
  750.                       GuiGadgetActiona(Gui,#Settags)
  751.                       Counter==Files
  752.                       Convertzahl(Files,0)
  753.                       Move.l Zusatz,Files1
  754.                       Move.l Zahl,Files
  755.                       Convertzahl(Dirs,0)
  756.                       Move.l Zusatz,Dirs1
  757.                       Move.l Zahl,Dirs
  758.                       CD("Base-CD:")
  759.                       OK=Countstring(#CDName)
  760.                       Buffer=="Base-CD:"+Left$(CDName,ok)+".Index"
  761.                       Crunch(#Buffer)
  762.                       Buffer=="Es sind "+Left$(Files,5)+" Files und "+Left$(Dirs,5)+" Dirs in "+CDName
  763.                       GuiRequestA(GUi,#Buffer,#GER_okkind,#OKTAGS)
  764.                       bra WaitMessage
  765.                     }
  766.     If MsgGadNbr=#2 {
  767.                       Progress(6,0)
  768.                       GetCDName(#Device)
  769.                       OK=Countstring(#CDName)
  770.                       Buffer=="Base-CD:"+Left$(CDName,ok)+".Index"
  771.                       FH=Open(#Buffer,#Mode_old)
  772.                       Decrunch(#FH)
  773.                       If FH##0 {
  774.                                  Found==0
  775.                                  FileReq(0)
  776.                                  CheckF Result,.close2
  777.                                  Filelock=Lock(#name_bak,#Access_Read)
  778.                                  NameFromLock(Filelock,#Buffer+2,300)
  779.                                  Unlock(Filelock)
  780.                                  OK=CountString(#Buffer+2)
  781.                                  lea Buffer,a0
  782.                                  Move.w #"#?",(a0)+
  783.                                  add.l ok,a0
  784.                                  Move.w #"#?",(a0)+
  785.                                  WH=Open("T:Swap",#Mode_New)
  786.                                  IsWild=ParsePatternNoCase(#Buffer,#FIB,300)
  787.                                  bra .SchleifeY
  788. .SchleifeX:
  789.                                  Fputs(WH,#Buffer)
  790. .SchleifeY:
  791.                                  Result=Fgets(FH,#Buffer,1000)
  792.                                  If Result##Buffer --> .close2
  793.                                  Match=MatchPatternNoCase(#FIB,#Buffer)
  794.                                  CheckF Match,.SchleifeX
  795.                                  Found==1
  796.                                  Bra .SchleifeY
  797. .close2:
  798.                                  Close(WH)
  799.                                  Close(FH)
  800.                                  Progress(6,50)
  801.                                  If Found=#1 {
  802.                                                OK=Countstring(#CDName)
  803.                                                Buffer=="Base-CD:"+Left$(CDName,ok)+".Index"
  804.                                                FH=Open("T:Swap",#Mode_old)
  805.                                                WH=Open(#buffer,#Mode_new)
  806.                                                Copy(FH,WH)
  807.                                                Close(WH)
  808.                                                Close(FH)
  809.                                                OK=Countstring(#CDName)
  810.                                                Buffer=="Base-CD:"+Left$(CDName,ok)+".Index"
  811.                                                Crunch(#Buffer)
  812.                                              }
  813.                                 Progress(5,100)
  814.                                }
  815.                     }
  816.     If MsgGadNbr=#3 {
  817.                       Progress(6,0)
  818.                       Counter==0
  819.                       Files==0
  820.                       Merker==0
  821.                       Dirs==0
  822.                       Treffer==0
  823.                       Index=GetIndex()
  824.                       CopyMem(#Suchtext,#Buffer+2,100)
  825.                       OK=CountString(#Buffer+2)
  826.                       Lea Buffer,a0
  827.                       Move.w #"#?",(a0)+
  828.                       Add.l ok,a0
  829.                       Move.w #"#?",(a0)+
  830.                       IsWild=ParsePatternNoCase(#buffer,#SuchText,100)
  831.                       If Searchonly##0 {
  832.                                           Copymem("Base-CD:\$00",#Dirname,?)
  833.                                           Copymem("\$00",#Filename,?)
  834.                                           FileReq(0)
  835.                                           Zeiger==#Name_Bak
  836.                                           Index==1
  837.                                           bra .in
  838.                                        }
  839.                       Dirlock=Lock("Base-CD:",#access_read)
  840.                       FillBuffer(#Fib,0,300)
  841.                       Examine(Dirlock,#FIB)
  842. .SchleifeZ1:
  843.                       If searchonly##0 --> .close4a
  844.                       OK=ExNext(Dirlock,#FIB)
  845.                       CheckF Ok,.close4
  846.                       Zeiger=8(#Fib)
  847. .in:
  848.                       Dirs==Dirs++
  849.                       Pro==Dirs*100
  850.                       Pro==Pro/Index
  851.                       Progress(6,Pro)
  852.                       FH=Open(Zeiger,#Mode_Old)
  853.                       Decrunch(#FH)
  854.                       If (Zeiger=TestFilename(Fh,"T:swap.decrunch"))##0 --> .SchleifeZ2
  855. .SchleifeZ:
  856.                                  Result=Fgets(FH,#Buffer,1000)
  857.                                  If Result##Buffer --> .close3
  858.                                  ProgressFiles()
  859.                                  Match=MatchPatternNoCase(#SuchText,#Buffer)
  860.                                  CheckF Match,.SchleifeZ
  861.                                  Treffer==Treffer++
  862.                                  OK=Countstring(#Buffer)
  863.                                  Write(Oh,#Buffer,OK)
  864.                                  bra .SchleifeZ
  865. .SchleifeZ3:
  866.                                  OK=Countstring(Zeiger)
  867.                                  Zeiger==Zeiger+OK
  868.                                  Zeiger==Zeiger++
  869. .SchleifeZ2:
  870.                                  Result=Rgets(Zeiger)
  871.                                  If Result=#0 --> .close3a
  872.                                  ProgressFiles()
  873.                                  Match=MatchPatternNoCase(#SuchText,Zeiger)
  874.                                  CheckF Match,.SchleifeZ3
  875.                                  Treffer==Treffer++
  876.                                  OK=Countstring(Zeiger)
  877.                                  Write(Oh,Zeiger,OK)
  878.                                  Write(Oh,"\n",1)
  879.                                  Zeiger==Zeiger+OK
  880.                                  Zeiger==Zeiger++
  881.                                  bra .SchleifeZ2
  882. .close3a:
  883.                       Freemem(Memoryblock,laenge)
  884. .close3:
  885.                       NamefromFH(FH,#Buffer,1000)                      
  886.                       Filepointer=FilePart(#Buffer)
  887.                       Match=Comparestring(FilePointer,"swap.decrunch",0,#Mode_Nocase)
  888.                       If Match##0 --> .close6
  889.                       Close(FH)
  890.                       bra .Schleifez1
  891. .close6:
  892.                       Close(FH)
  893.                       Deletefile(#Buffer)
  894.                       bra .Schleifez1
  895. .close4:
  896.                       Unlock(Dirlock)
  897. .Close4a:             Convertzahl(Treffer,OH)
  898.                       Write(OH," Treffer in ",?)
  899.                       Convertzahl(Counter,OH)
  900.                       Write(OH," Einträgen durchsucht auf ",?)
  901.                       Convertzahl(Index,OH)
  902.                       Write(OH," CD's!\n",?)
  903.                       Progress(6,100)
  904.                     }
  905.     If MsgGadNbr=#5 {
  906.                       Progress(6,0)
  907.                       FileReq(0)
  908.                       CheckF Result,WaitMessage
  909.                       FH=Open(#name_bak,#Mode_old)
  910.                       CheckF FH,WaitMessage
  911.                       OK=CountString(#Name)
  912.                       Buffer=="Base-CD:"+Left$(Name,ok)+".Index"
  913.                       WH=Open(#Buffer,#Mode_NEW)
  914.                       CheckF WH,.Close5
  915.                       OK=AminetCheck(FH)
  916.                       Checkf Ok,.close5
  917.                       Copy(FH,WH)
  918. .close5:              
  919.                       Close(FH)
  920.                       Close(WH)
  921.                       Buffer=="Base-CD:"+Left$(Name,ok)+".Index"
  922.                       Crunch(#buffer)                      
  923.                       Progress(6,100)
  924.                     }
  925.     If MsgGadNbr=#8 {
  926.                       Progress(6,0)
  927.                       Copymem("Base-CD:\$00",#Dirname,?)
  928.                       Copymem(".Index\$00",#Filename,?)
  929.                       FileReq(0)
  930.                       CheckF Result,WaitMessage
  931.                       FH=Open(#Name_bak,#Mode_old)
  932.                       CheckF FH,WaitMessage
  933.                       Decrunch(#FH)
  934.                       NamefromFH(fh,#Buffer,1000)
  935.                       Close(FH)
  936.                       EinScannen()
  937.                       DeleteFile(#Buffer)
  938.                       Progress(6,100)
  939.                     }
  940.     If MsgGadNbr=#9 {
  941.                       Progress(6,0)
  942.                       Copymem("Base-CD:",#Dirname,?)
  943.                       Copymem(".Index\$00",#name,?)
  944.                       FileReq(0)
  945.                       CheckF Result,WaitMessage
  946.                       FH=Open(#Name_bak,#Mode_old)
  947.                       CheckF FH,WaitMessage
  948.                       Seek(FH,0,#Offset_end)
  949.                       Laenge=Seek(FH,0,#Offset_begin)
  950.                       Decrunch(#FH)
  951.                       NamefromFH(fh,#Buffer,1000)
  952.                       Seek(FH,0,#Offset_end)
  953.                       Laenge2=Seek(FH,0,#Offset_begin)
  954.                       Close(FH)
  955.                       DeleteFile(#Buffer)
  956.                       IndexWindow=OpenGuiWindowA(000,011,300,110,"CD-Finder Status",
  957.                                     #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_CLOSEWINDOW!IDCMP_IDCMPupdate,
  958.                                     #WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_RMBTRAP!0,0,0)
  959.                       Checkf IndexWindow,WaitMessage
  960.                       IndexGUI=CreateGuiInfoA(IndexWindow,0)
  961.                       OK=Countstring(#name)
  962.                       OK==OK-6
  963.                       OK==OK+#name
  964.                       Copymem("\$00",OK,1)
  965.                       Convertzahl(Laenge,0)
  966.                       Copymem(#zusatz,#gepackt_txt,8)
  967.                       Copymem(" Bytes",#gepackt_Txt+8,?)  
  968.                       Convertzahl(Countfiles,0)
  969.                       Copymem(#zusatz,#Files_txt,8)
  970.                       Copymem(" Stück",#Files_Txt+8,?)  
  971.                       Convertzahl(CountDirs,0)
  972.                       Copymem(#zusatz,#Dirs_txt,8)
  973.                       Copymem(" Stück",#Dirs_Txt+8,?)  
  974.                       Convertzahl(Laenge2,0)
  975.                       Copymem(#zusatz,#ungepackt_txt,8)
  976.                       Copymem(" Bytes",#ungepackt_Txt+8,?)  
  977.                       Laenge==Laenge*100
  978.                       Laenge==Laenge/Laenge2
  979.                       Convertzahl(Laenge,0)
  980.                       Copymem("          ",#Ratio_txt,?)
  981.                       Copymem(#zahl+1,#ratio_txt+5,3)
  982.                       Copymem("%",#Ratio_Txt+9,?)  
  983.                       CreateGuiGadgetA(IndexGui,90,10,200,013,#Text_Kind,
  984.                        >GadgetI00Tags:GEG_Description,0|
  985.                                       GTTX_Border,1|
  986.                                       GEG_Text,GadgetI00Text="Volumen:"|
  987.                                       GTTX_Text,name|
  988.                                       Tag_done,0)
  989.                       CreateGuiGadgetA(IndexGui,90,40,200,013,#Text_Kind,
  990.                        >GadgetI01Tags:GEG_Description,0|
  991.                                       GTTX_Border,1|
  992.                                       GEG_Text,GadgetI01Text="Gepackt:"|
  993.                                       GTTX_Text,gepackt_txt|
  994.                                       Tag_done,0)
  995.                       {* Incblock: gepackt_TXT,100*}
  996.                       CreateGuiGadgetA(IndexGui,90,25,200,013,#Text_Kind,
  997.                        >GadgetI02Tags:GEG_Description,0|
  998.                                       GTTX_Border,1|
  999.                                       GEG_Text,GadgetI02Text="Ungepackt:"|
  1000.                                       GTTX_Text,ungepackt_txt|
  1001.                                       Tag_done,0)
  1002.                       {* Incblock: ungepackt_TXT,100*}
  1003.                       CreateGuiGadgetA(IndexGui,90,55,200,013,#Text_Kind,
  1004.                        >GadgetI03Tags:GEG_Description,0|
  1005.                                       GTTX_Border,1|
  1006.                                       GEG_Text,GadgetI03Text="Ratio:"|
  1007.                                       GTTX_Text,Ratio_txt|
  1008.                                       Tag_done,0)
  1009.                       {* Incblock: Ratio_TXT,100*}
  1010.                       CreateGuiGadgetA(IndexGui,90,70,200,013,#Text_Kind,
  1011.                        >GadgetI04Tags:GEG_Description,0|
  1012.                                       GTTX_Border,1|
  1013.                                       GEG_Text,GadgetI04Text="Files:"|
  1014.                                       GTTX_Text,Files_txt|
  1015.                                       Tag_done,0)
  1016.                       {* Incblock: Files_TXT,100*}
  1017.                       CreateGuiGadgetA(IndexGui,90,85,200,013,#Text_Kind,
  1018.                        >GadgetI05Tags:GEG_Description,0|
  1019.                                       GTTX_Border,1|
  1020.                                       GEG_Text,GadgetI05Text="Dirs:"|
  1021.                                       GTTX_Text,Dirs_txt|
  1022.                                       Tag_done,0)
  1023.                       {* Incblock: Dirs_TXT,100*}
  1024.                       DrawGuiA(IndexGui,0)
  1025.                       Progress(6,100)
  1026.                       CloseGuiWindow(IndexWindow)
  1027.                     }
  1028.     If MsgGadNbr=#10 {
  1029.                         Progress(6,0)
  1030.                         IndexWindow=OpenGuiWindowA(000,011,640,200,"CD-Finder Export",
  1031.                          #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_CLOSEWINDOW!IDCMP_REFRESHWINDOW!IDCMP_VANILLAKEY!IDCMP_MOUSEBUTTONS,
  1032.                          #WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_RMBTRAP!0,0,0)
  1033.                         Checkf IndexWindow,WaitMessage
  1034.                         SelectedNodeZeiger==#SelectedNodespeicher
  1035.                         Jsr Indexliste_erstellen
  1036.                         {* Flush *}
  1037.                         IndexGUI=CreateGuiInfoA(IndexWindow,0)
  1038.                     CreateGuiGadgetA(IndexGui,10,115,200,015,#String_Kind,
  1039.                             >GadgetE00Tags:GEG_Description,0|
  1040.                                                        GEG_Flags,016|
  1041.                                                        GEG_Varaddress,IndexItem|
  1042.                                                        Tag_done,0)
  1043.                     {* IncSysBlock: IndexItem,100*}
  1044.                         GuiGadgetinfo100=GetGuiGadgetA(IndexGui,000,#GEG_Address)
  1045.                           lea GadgetE01tags,a0
  1046.                     4(a0)==GuiGadgetInfo100
  1047.                          CreateGuiGadgetA(IndexGui,010,015,200,0100,#Listview_Kind,
  1048.                                    >GadgetE01Tags:
  1049.                                         GTLV_ShowSelected,GuiGadgetinfo100|
  1050.                                         GEG_Description,0|
  1051.                             GEG_Text,GADGETE01Text="Indexfiles:"|
  1052.                                     GEG_Flags,004|
  1053.                             GEG_Varaddress,LV_Index|
  1054.                                     GTLV_Labels,Index_Labs|
  1055.                             Tag_done,0)
  1056.                         {* Incvar: LV_index,Lv_Selected*}
  1057.                         CreateGuiGadgetA(IndexGui,250,115,200,015,#String_Kind,
  1058.                             >GadgetE02Tags:GEG_Description,0|
  1059.                                                        GEG_Flags,016|
  1060.                                                        GEG_Varaddress,SelectedItem|
  1061.                                                        Tag_done,0)
  1062.                     {* IncSysBlock: SelectedItem,100*}
  1063.                         GuiGadgetinfo101=GetGuiGadgetA(IndexGui,002,#GEG_Address)
  1064.                           lea GadgetE03tags,a0
  1065.                     4(a0)==GuiGadgetInfo101
  1066.                     CreateGuiGadgetA(IndexGui,250,015,200,0100,#Listview_Kind,
  1067.                                        >GadgetE03Tags:
  1068.                                         GTLV_ShowSelected,GuiGadgetinfo100|
  1069.                                         GEG_Description,0|
  1070.                                    GEG_Text,GADGETE03Text="Selected"|
  1071.                             GEG_Flags,004|
  1072.                             GEG_Varaddress,LV_Selected|
  1073.                             GTLV_Labels,Selected_Labs|
  1074.                             Tag_done,0)
  1075.                     CreateGuiGadgetA(IndexGui,070,120,160,013,#Cycle_Kind,
  1076.                             >GadgetE04Tags:GEG_Description,0|
  1077.                             GEG_Text,GADGETE04Text="_Output:"|
  1078.                             GEG_Flags,001|
  1079.                             GEG_Varaddress,CYCLE_Index|
  1080.                             GTCY_Labels,Cycle_Labs|
  1081.                             Tag_done,0)
  1082.                         {* IncVar: Cycle_index*}
  1083.                     CreateGuiGadgetA(IndexGui,230,120,200,013,#String_Kind,
  1084.                             >GadgetE05Tags:GEG_Description,0|
  1085.                                         GEG_Varaddress,Name_bak|
  1086.                             GEG_Flags,016|
  1087.                             Tag_done,0)
  1088.                     CreateGuiGadgetA(IndexGui,430,120,040,013,#Button_Kind,
  1089.                             >GadgetE06Tags:GEG_Description,0|
  1090.                                GEG_Text,GADGETE06Text="_REQ"|
  1091.                             GEG_Flags,016|
  1092.                             Tag_done,0)
  1093.                         CreateGuiGadgetA(IndexGui,470,120,160,013,#Cycle_Kind,
  1094.                             >GadgetE07Tags:GEG_Description,0|
  1095.                             GEG_Text,GADGETE07Text="Dateityp:"|
  1096.                             GEG_Flags,004|
  1097.                             GEG_Varaddress,Type_Index|
  1098.                             GTCY_Labels,DateiType_Labs|
  1099.                             Tag_done,0)
  1100.                         {* IncVar: Type_index*}
  1101.                     CreateGuiGadgetA(IndexGui,210,40,040,015,#Button_Kind,
  1102.                             >GadgetE08Tags:GEG_Description,0|
  1103.                                GEG_Text,GADGETE08Text=" --> "|
  1104.                             GEG_Flags,016|
  1105.                             Tag_done,0)
  1106.                     CreateGuiGadgetA(IndexGui,210,55,040,015,#Button_Kind,
  1107.                             >GadgetE09Tags:GEG_Description,0|
  1108.                                GEG_Text,GADGETE09Text=" <-- "|
  1109.                             GEG_Flags,016|
  1110.                             Tag_done,0)
  1111.                     CreateGuiGadgetA(IndexGui,10,135,100,013,#Button_Kind,
  1112.                             >GadgetE10Tags:GEG_Description,0|
  1113.                                GEG_Text,GADGETE10Text="_Export"|
  1114.                             GEG_Flags,016|
  1115.                             Tag_done,0)
  1116.                     CreateGuiGadgetA(IndexGui,120,138,240,06,#GEG_ProgressIndicatorKind,
  1117.                             >GadgetE11Tags:GEG_Description,0|
  1118.                                            GEG_Flags,016|
  1119.                             Tag_done,0)
  1120.                     DrawGuiA(IndexGui,0)
  1121. .WaitMessage1:
  1122.                       {* Flush *}
  1123.                       WaitGuiMsg(IndexGui)
  1124.                       MsgClass=.l36(IndexGui)
  1125.                       MsgCode=.w40(IndexGui)
  1126.                       MsgGadNbr=.w52(IndexGui)
  1127.                       If MsgClass=#IDCMP_CloseWindow  --> .CloseWindow
  1128.                       GuigadgetActiona(IndexGui,#GetTags)
  1129.                       If MsgGadnbr=#6 {
  1130.                                         Copymem("Turbocalc:",#Dirname,?)
  1131.                                         Copymem(".index\$00",#Filename,?)
  1132.                                         FileReq(0)
  1133.                                         CheckF Result,.WaitMessage1
  1134.                                         GuiGadgetActiona(IndexGui,>Set5tag:GEG_SetVar,5|Tag_done,Null)
  1135.                                       }
  1136.                       If MsgGadNbr=#8 {
  1137.                                         move.l LV_Index,d0
  1138.                                         Swap D0
  1139.                                         Andi.l #$FFFF,d0
  1140.                                         mulu.l #4,d0
  1141.                                         move.l d0,a0
  1142.                                         add.l #IndexItems,a0
  1143.                                         move.l Selectednodezeiger,a5
  1144.                                         Move.l (a0),10(a5)
  1145.                                         Addtail(#Selected_labs,a5)
  1146.                                         Lea 14(a5),a5
  1147.                                         Move.l a5,Selectednodezeiger
  1148.                                         SetGuiGadgetA(IndexGui,3,>SetNewItem:GTLV_Labels,Selected_Labs|Tag_done,Null)
  1149.                                        }
  1150.                       If MsgGadNbr=#9 {
  1151.                                         Node=FindName(#Selected_labs,#SelectedItem)
  1152.                                         Zeiger=.l10(Node)
  1153.                                         Remove(Node)
  1154.                                         FreeMem(Zeiger,108)
  1155.                                         SelectedNodeZeiger==SelectedNodeZeiger-14
  1156.                                         FillBuffer(SelectedNodeZeiger,0,14)
  1157.                                         SetGuiGadgetA(IndexGui,3,#SetNewItem)
  1158.                                        }
  1159.                       bra .WaitMessage1
  1160.                       
  1161. .Closewindow:
  1162.                       jsr Remove_Indexliste
  1163.                       jsr Remove_Selectedliste
  1164.                       {* Flush *}
  1165.                       CloseGuiWindow(IndexWindow)
  1166.                       Progress(6,100)
  1167.                     }
  1168. WaitMessage1:
  1169.     If MsgGadNbr=#12 {
  1170.                        Prefs()
  1171.                      }
  1172.     Bra WaitMessage
  1173.  
  1174. CDENDEError:
  1175.     Unlock(CDlock)
  1176.     GUIRequestA(Gui,"Konnte kein Indexfile anlegen!",#GER_Okkind,#OKTAGS)
  1177.     Bra WaitMessage
  1178. CantLock:
  1179.     GUIRequestA(Gui,"Device nicht gefunden, bitte CD einlegen!",#GER_Okkind,#OKTAGS)
  1180.     Bra WaitMessage
  1181. PRG_Ende:
  1182.     If Window##0 { 
  1183.                   jsr Close_window
  1184.                  }
  1185.     CD("Progdir:")
  1186.     IF OO=#0 do Close(OH)
  1187.     IF (TH=Open("Env:Cd-Finder.dat",#Mode_old))##0 {
  1188.                                                      Write(TH,#Status,4)
  1189.                                                      Write(TH,#Searchonly,4)
  1190.                                                      Close(TH)
  1191.                                                    }
  1192.     RTS
  1193.  
  1194.  
  1195. IndexListe_erstellen:
  1196.     Dirlock=Lock("Base-CD:",#Access_read)
  1197.     FillBuffer(#Fib,0,300)
  1198.     Examine(Dirlock,#FIB)
  1199.     lea IndexItems,a4
  1200. .Schleife:
  1201.     {* Flush *}
  1202.     OK=Exnext(Dirlock,#FIB)
  1203.     CheckF OK,.dirende
  1204.     Type=.l4(#FIB)
  1205.     If Type>#0 --> .Schleife
  1206.     Zeiger=8(#FIB)
  1207.     Memoryblock=AllocMem(108,#MEMF_public)
  1208.     Checkf Memoryblock,.dirende
  1209.     move.l memoryblock,(a4)+
  1210.     Copymem(Zeiger,Memoryblock,108)
  1211.     bra .Schleife
  1212. .Dirende:
  1213.     Unlock(Dirlock)
  1214.     lea IndexItems,a4
  1215.     lea IndexNodespeicher,a5
  1216. .node1:    
  1217.     Checkf (a4),.node2
  1218.        move.l (a4)+,10(a5)
  1219.        Addtail(#Index_labs,a5)
  1220.        lea 14(a5),a5
  1221.        bra .node1
  1222. .node2:
  1223.     Move.l a5,Indexnodezeiger
  1224.     RTS
  1225.  
  1226. Remove_SelectedListe:
  1227.     Node=RemTail(#Selected_Labs)
  1228.     CheckT Node,Remove_SelectedListe
  1229.     FillBuffer(#Selectednodespeicher,0,5024)
  1230.     RTS
  1231.  
  1232. Remove_IndexListe:
  1233.     Node=RemTail(#Index_Labs)
  1234.     CheckT Node,Remove_IndexListe
  1235.     move.l #IndexItems,a5
  1236. .l1:move.l (a5)+,a1
  1237.     cmpi.l #0,a1
  1238.     beq .ende
  1239.     Freemem(a1,108)
  1240.     bra .l1    
  1241. .ende:        
  1242.     FillBuffer(#Indexnodespeicher,0,5024)
  1243.     FillBuffer(#IndexItems,0,1024)
  1244.     RTS
  1245.  
  1246. Readin[]:
  1247.     Copymem("Base-CD:",#Dirname,?)
  1248.     FileReq(0)
  1249.     FH=Open(#name_bak,#Mode_old)
  1250.     CheckF FH,.error
  1251.     WH=Open("T:DirTree.temp",#Mode_new)
  1252.     CheckF WH,.error1
  1253. .l1:
  1254.     Result=Fgets(FH,#Pfad,150)
  1255.     If Result##Pfad -> .ende
  1256.     cmpi.l #"CM01",pfad
  1257.     beq .l1
  1258.     cmpi.b #"%",pfad
  1259.     beq .l1
  1260.     Pathpart(#pfad)
  1261.     move.l d0,a0
  1262.     move.w #$0000,(a0)
  1263.     OK=Countstring(#pfad)
  1264.     OK==OK+1
  1265.     Write(WH,#Pfad,OK)
  1266. ;    Write(wh,"\n",1)
  1267.     bra .l1
  1268. .ende:
  1269.     Close(WH)
  1270.     Close(FH)
  1271.     FH=Open("T:DirTree.temp",#Mode_Old)
  1272.     CheckF FH,.error
  1273.     Seek(FH,0,#Offset_end)
  1274.     Len=Seek(FH,0,#Offset_begin)
  1275.     Memoryblock=AllocMem(Len,#MEMF_Public)
  1276.     CheckF memoryblock,.error1
  1277.     Read(FH,Memoryblock,len)
  1278.     Close(FH)
  1279.     Deletefile("T:Dirtree.temp")
  1280.     move.l Memoryblock,d0
  1281.     move.l Len,d1
  1282.     RTS
  1283. .error1:
  1284.     {* Flush *}
  1285.     Close(FH)
  1286. .error:
  1287.     moveq.l #0,d0
  1288.     RTS
  1289.  
  1290. EntryLevel[a0,d1]:
  1291.     movem.l a2-a6/d0-d7,-(a7)
  1292.     moveq.l #0,d0
  1293. .count:
  1294.     addq.l #1,d0
  1295.     cmpi.l d0,d1
  1296.     beq .write
  1297.     lea 1(a0),a0
  1298. .CountCells1:
  1299.     cmpi.b #0,(a0)
  1300.     beq .ERROR
  1301.     cmpi.b #`:`,(a0)
  1302.     beq .count
  1303.     cmpi.b #`/`,(a0)
  1304.     beq .Count
  1305.     lea 1(a0),a0
  1306.     bne .CountCells1
  1307. .Write:
  1308.     cmpi.l #1,d1
  1309.     beq .write0
  1310.     lea 1(a0),a0
  1311. .write0:
  1312.     move.l a0,a1
  1313. .weiter:
  1314.     cmpi.b #`:`,(a0)
  1315.     beq .next
  1316.     cmpi.b #`/`,(a0)
  1317.     beq .next
  1318.     cmpi.b #$0a,(a0)
  1319.     beq .next
  1320.     cmpi.b #$00,(a0)
  1321.     beq .next
  1322.     lea 1(a0),a0
  1323.     bra .weiter
  1324. .next:
  1325.     sub.l a1,a0
  1326.     movem.l (a7)+,a2-a6/d0-d7
  1327.     RTS
  1328. .error:
  1329.     move.l #0,a0
  1330.     move.l #0,a1
  1331.     bra .next
  1332.  
  1333. DrawTree_Lines[A2]:
  1334.     move.l (a2),a1
  1335.     OK=Countstring(a1)
  1336.     move.l 4(a2),A1
  1337.     cmpi.l #0,a1
  1338.     beq .l1
  1339.     move.l a2,-(a7)
  1340.     move.l von,-(a7)
  1341.     jsr Write_line_Sub
  1342.     DrawTree_Lines(A1)
  1343.     move.l (a7)+,von
  1344.     move.l (a7)+,a2
  1345. .l1:
  1346.     move.l 8(a2),A1
  1347.     cmpi.l #0,a1
  1348.     beq .l2
  1349.     jsr Write_line_next
  1350.     Move.l a1,a2
  1351.     bra DrawTree_Lines
  1352.  
  1353. .l2:                            ; Stack:  09080706050403020100
  1354.     RTS
  1355.  
  1356. Write_line_Sub:
  1357.     move.l 28(a2),Von
  1358.     move.l 28(a1),Bis
  1359.     movem.l a0-a1,-(a7)
  1360.     Write(FH,#von,4)
  1361.     Write(FH,#Bis,4)
  1362.     movem.l (a7)+,a0-a1
  1363.     RTS
  1364.  
  1365. Write_line_Next:
  1366.     move.l 28(a1),Bis
  1367.     movem.l a0-a1,-(a7)
  1368.     Write(FH,#von,4)
  1369.     Write(FH,#Bis,4)
  1370.     movem.l (a7)+,a0-a1
  1371.     RTS
  1372.  
  1373.  
  1374. DrawTree_Punkte[A2]:
  1375.     For I=0 to Entries
  1376.         Lines==0
  1377.         Drawtree_Sub(Tree)
  1378.         Write(FH,#X,4)
  1379.         Write(FH,#Y,4)
  1380.         Write(FH,#Z,4)
  1381.         Write(FH,namenzeiger,20)
  1382.     Next I
  1383.     RTS
  1384.  
  1385. DrawTree_Sub:
  1386.     {* Incvar: Namenzeiger*}
  1387.     Lines==Lines+1
  1388.     move.l (a2),a1
  1389.     OK=Countstring(a1)
  1390.     move.l 28(a2),d0
  1391.     cmpi.l I,d0
  1392.     bne .l0
  1393.     move.l 0(a2),Namenzeiger
  1394.     move.l 16(a2),X
  1395.     move.l 20(a2),Y
  1396.     move.l 24(a2),Z
  1397.     RTS
  1398. .l0:move.l 4(a2),A1
  1399.     cmpi.l #0,a1
  1400.     beq .l1
  1401.     move.l a2,-(a7)
  1402.     DrawTree_SUB(A1)
  1403.     move.l (a7)+,a2
  1404. .l1:
  1405.     move.l 8(a2),A1
  1406.     cmpi.l #0,a1
  1407.     beq .l2
  1408.     move.l a2,-(a7)
  1409.     DrawTree_SUB(A1)
  1410.     move.l (a7)+,a2
  1411. .l2:
  1412.     RTS
  1413.  
  1414.  
  1415. Deep[a2]:
  1416.     movem.l a0-a6,-(a7)
  1417.     For I=1 to 255
  1418.         Entrylevel(a2,I)
  1419.         cmpi.l #0,a0
  1420.         beq .ende
  1421.     Next I
  1422. .ende:
  1423.     I==I--
  1424.     movem.l (a7)+,a0-a6
  1425.     move.l I,d0
  1426.     RTS
  1427.  
  1428. Entry[Tree,a5]:
  1429.     move.l #0,Y
  1430.     Bis=Deep(a5)
  1431.     Copymem(Tree,#Eintrag,#Eintraglaenge)
  1432.     Move.l Tree,Adresse
  1433.     For I=1 to Bis
  1434.         move.l #0,X
  1435.         EntryLevel(a5,I)
  1436.         Movem.l a0-a1,-(a7)
  1437.         Fillbuffer(#buffer,0,100)
  1438.         Movem.l (a7)+,a2-a3
  1439.         Copymem(a3,#Buffer,a2)
  1440.         Addi.l #1,a2
  1441.         Move.l I,d0
  1442.         Muls.l #50,d0
  1443.         Move.l d0,Z
  1444. .again:
  1445.         If Char=#0 {
  1446.                      Mem1=AllocMem(a2,#Memf_Public)
  1447.                      CheckF mem1,.error
  1448.                      Copymem(#Buffer,mem1,a2)
  1449.                      move.l mem1,char
  1450.                      Copymem(#Eintrag,Adresse,#Eintraglaenge)
  1451.                      bra .found
  1452.                    }
  1453.         OK=ComparePfad(Char,#Buffer)
  1454.         Checkt OK,.found
  1455.         If  next=#0 {
  1456.                      Entries==Entries+1
  1457.                      Mem=Allocmem(#Eintraglaenge,#Memf_public)
  1458.                      CheckF mem,.error
  1459.                      Mem1=AllocMem(a2,#Memf_Public)
  1460.                      CheckF mem1,.error2
  1461.                      Move.l mem,a0
  1462.                      Move.l MEM1,(a0)+
  1463.                      Move.l #0,(a0)+
  1464.                      Move.l #0,(a0)+
  1465.                      Move.l Adresse,(a0)+
  1466.                      Move.l X,d0
  1467.                      Add.l #50,d0
  1468.                      Move.l d0,(a0)+
  1469.                      Move.l Y,d0
  1470.                      Add.l #50,d0
  1471.                      Move.l d0,(a0)+
  1472.                      Move.l Z,(a0)+
  1473.                      Move.l Entries,(a0)+
  1474.                      Move.l Mem,Next
  1475.                      CopyMem(a3,mem1,a2)
  1476.                      move.l mem1,a0     
  1477.                      add.l a2,a0
  1478.                      move.b #0,-1(a0)
  1479.                      Copymem(#Eintrag,Adresse,#Eintraglaenge)
  1480.                      move.l next,Adresse
  1481.                      CopyMem(Next,#Eintrag,#Eintraglaenge)
  1482.                      Move.l X,d0
  1483.                      add.l #50,d0
  1484.                      move.l d0,X
  1485.                      Move.l Y,d0
  1486.                      add.l #50,d0
  1487.                      move.l d0,Y
  1488.                      bra .found
  1489.                     }
  1490.         move.l next,Adresse
  1491.         CopyMem(Next,#Eintrag,#Eintraglaenge)
  1492.         bra .Again
  1493. .found:
  1494.         IF I=Bis --> .tonext
  1495.         If Sub=#0 {
  1496.                      Entries==Entries+1
  1497.                      Mem=Allocmem(#Eintraglaenge,#Memf_public)
  1498.                      CheckF mem,.error
  1499.                      move.l mem,a0
  1500.                      move.l #0,(a0)+
  1501.                      move.l #0,(a0)+
  1502.                      move.l #0,(a0)+
  1503.                      Move.l Adresse,(a0)+
  1504.                      move.l X,(a0)+
  1505.                      Move.l Y,(a0)+
  1506.                      Move.l Z,(a0)+
  1507.                      Move.l Entries,(a0)+
  1508.                      move.l mem,Sub
  1509.                      Copymem(#Eintrag,Adresse,#Eintraglaenge)
  1510.                    }
  1511.         move.l sub,Adresse
  1512.         Copymem(Sub,#Eintrag,#Eintraglaenge)
  1513. .tonext:
  1514.     Next I
  1515.     RTS
  1516. .error2:
  1517.     FreeMem(mem,#Eintraglaenge)
  1518. .error:
  1519.     move.l #0,d0
  1520.     RTS
  1521.  
  1522. DrawTree[a2]:
  1523.     move.l (a2),a1
  1524.     OK=Countstring(a1)
  1525.     move.l 16(a2),X
  1526.     move.l 20(a2),Y
  1527.     move.l 24(a2),Z
  1528.     Write(Oh,a1,ok)
  1529.     Write(oh,":X=",3)
  1530.     Convertzahl(X,OH)
  1531.     Write(oh,":Y=",3)
  1532.     Convertzahl(Y,OH)
  1533.     Write(oh,":Z=",3)
  1534.     Convertzahl(Z,OH)
  1535.     Write(oh,"\n",1)
  1536.     move.l 4(a2),A1
  1537.     cmpi.l #0,a1
  1538.     beq .l1
  1539.     move.l a2,-(a7)
  1540.     DrawTree(A1)
  1541.     move.l (a7)+,a2
  1542. .l1:
  1543.     move.l 8(a2),A1
  1544.     cmpi.l #0,a1
  1545.     beq .l2
  1546.     move.l a2,-(a7)
  1547.     DrawTree(A1)
  1548.     move.l (a7)+,a2
  1549. .l2:
  1550.     RTS
  1551.  
  1552. BuildTree[]:
  1553.     Entries==1
  1554.     Zeiger==Memoryblock
  1555.     Fillbuffer(#buffer,0,100)
  1556.     OK=Entry(Tree,Zeiger)
  1557.     Checkf OK,.ende
  1558. .Schleife:
  1559.     Zeiger=Rgets2(Zeiger)
  1560.     If Zeiger=#0 --> .ende
  1561.     OK=Entry(Tree,Zeiger)
  1562.     Checkf OK,.ende
  1563.     bra .Schleife
  1564. .ende:
  1565.     RTS
  1566.  
  1567. MakeTree[]:
  1568.     move.l #0,Char
  1569.     move.l #0,Sub
  1570.     move.l #0,Next
  1571.     move.l #0,Last
  1572.     move.l #0,X
  1573.     move.l #0,Y
  1574.     move.l #0,Z
  1575.     move.l #1,EntryNr
  1576.     Zeiger=Allocmem(#Eintraglaenge,#Memf_Public)
  1577.     Checkf Zeiger,.error
  1578.     Copymem(#Eintrag,Zeiger,#Eintraglaenge)
  1579.     move.l Zeiger,d0
  1580.     RTS
  1581. .error:
  1582.     {* Returnq 0*}    
  1583.                  
  1584. KillTree[a2]:
  1585.     move.l 4(a2),A1
  1586.     cmpi.l #0,a1
  1587.     beq .l1
  1588.     move.l a2,-(a7)
  1589.     KillTree(A1)
  1590.     move.l (a7)+,a2
  1591. .l1:
  1592.     move.l 8(a2),A1
  1593.     cmpi.l #0,a1
  1594.     beq .l2
  1595.     move.l a2,-(a7)
  1596.     KillTree(A1)
  1597.     move.l (a7)+,a2
  1598. .l2:
  1599.     move.l (a2),a1
  1600.     OK=Countstring(a1)
  1601.     checkf Ok,.l3
  1602.     OK==OK+1
  1603.     freemem(a1,ok)
  1604. .l3:
  1605.     {* Flush *}
  1606.     freemem(a2,#Eintraglaenge)
  1607.     RTS
  1608.  
  1609. Eintrag:
  1610. Char:   dc.l 0   ; Zeiger auf String Nullterminiert
  1611. Sub:    dc.l 0   ; Zeiger auf Subdir
  1612. Next:   dc.l 0   ; Zeiger auf NextEntry
  1613. Last:   dc.l 0   ; Zeiger auf PrevEntry
  1614. X:      dc.l 0   ; 
  1615. Y:      dc.l 0   ; 3d - Koordinate
  1616. Z:      dc.l 0   ;
  1617. EntryNr:dc.l 0   ; PunktNummer
  1618.  
  1619. Message:
  1620.         dc.l 0
  1621.         dc.l 0
  1622.         dc.b 5,0
  1623.         dc.l 0
  1624.         dc.l 0
  1625.         dc.w 0
  1626.